package com.twu.biblioteca.view;

import com.twu.biblioteca.models.Library;
import com.twu.biblioteca.models.Movie;


/**
 * Created with IntelliJ IDEA.
 * User: ema93sh
 * Date: 8/16/13
 * Time: 6:50 PM
 */
public class MovieView implements MenuItem {
    private Library library;

    public MovieView(Library library) {
        this.library = library;
    }

    @Override
    public String displayTitle() {
        return "Display all movies";
    }

    @Override
    public void doWork() {
        System.out.println("ID\t\tMovie\t\tYear\t\tDirector\t\tRating");
        int count =  1;
        for (Movie movie: library.getAllMovies())
        {
            System.out.println(count + ". " + movie.getName() + "\t\t" + movie.getYear()
                    + "\t\t" + movie.getDirector() + "\t\t" + displayMovieRating(movie));
            count++;
        }
        count--;
        System.out.println("Total:" + count);
    }

    public String displayMovieRating(Movie movie) {
        if (movie.isRated())
        {
            return Float.toString(movie.getRating());
        }
        return "N/A";
    }
}